From: Sam Spilsbury Date: Wed, 11 Oct 2017 10:42:04 +0000 (+0800) Subject: windowMenu: Check if monitorIndex is valid before using it X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~929^2~5^2~35 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c9bf72c5c4e8a94ff66fd191cb79165bed2831e5;p=gnome-shell.git windowMenu: Check if monitorIndex is valid before using it Calling meta_window_get_monitor on an unmanaged window may return -1, so we need to check the return value. https://bugzilla.gnome.org/show_bug.cgi?id=788882 --- diff --git a/js/ui/windowMenu.js b/js/ui/windowMenu.js index f0e564b7e..d4411d015 100644 --- a/js/ui/windowMenu.js +++ b/js/ui/windowMenu.js @@ -128,11 +128,10 @@ var WindowMenu = new Lang.Class({ let screen = global.screen; let nMonitors = screen.get_n_monitors(); - if (nMonitors > 1) { + let monitorIndex = window.get_monitor(); + if (nMonitors > 1 && monitorIndex >= 0) { this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - let monitorIndex = window.get_monitor(); - let dir = Meta.ScreenDirection.UP; let upMonitorIndex = screen.get_monitor_neighbor_index(monitorIndex, dir);